﻿/************************************************

* Function： N/A
* Name： RenderFunctionSlot
*
* Ver       Time                     Author
* 0.10      2023/1/12 10:28:12       ake
*
**************************************************/


using System;
using UnityEngine;
using UnityEngine.Rendering;

namespace Common
{
    public static class RenderFunctionSlot
    {
        public static Func<CommandBuffer> GetDamageNumberCommandBufferFunction;



        #region shader

        private static Func<string, Shader> _getShaderFunction = null;


        public static void BindShaderGetFunction(Func<string, Shader>  f)
        {
            _getShaderFunction = f;
        }

        public static Shader GetShader(string p)
        {
            Shader s = null;
            if (_getShaderFunction != null)
            {
                s = _getShaderFunction(p);
                if (s == null)
                {
                    // LogMgr.Error("get shader failed!!" + p);
                }
            }
            else
            {
                s = Shader.Find(p);
                if (Application.isPlaying)
                {
                    //Debug.LogError("获取shader失败 替换为Shader.Find：" + p);
                }
            }
            return s;
        }

        #endregion 

    }
}

